package com.example.snackfood.dao;

import com.example.snackfood.entity.Orders;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @program: snackFood
 * @description:
 * @author: lydms
 * @create: 2023-11-24 22:54
 **/

@Component
public class SnackFoodOrdersDao {


    @Resource
    private MongoTemplate mongoTemplate;


    public void save(Orders orders) {
        mongoTemplate.save(orders);
    }

    public void delete(Query query) {
        mongoTemplate.remove(query,Orders.class);
    }

    public Orders get(Query query) {
        return mongoTemplate.findOne(query,Orders.class);
    }

    public void update(Query query, Update update) {
        mongoTemplate.updateMulti(query,update,Orders.class);
    }
}
